<blockquote class="layui-elem-quote">
  <div class="layui-inline">
    <i class="layui-icon layui-icon-list layui-head-icon"></i>
    <span class="layui-font-16 layui-font-green">文章管理</span>
  </div>
  <div class="layui-pull-right">
    <a class="layui-btn layui-btn-primary layui-border-green" href="{:url('/store/article/create')}">添加文章</a>
  </div>
</blockquote>
<div class="layui-card">
  <div class="layui-card-body">
    <fieldset class="layui-elem-field">
      <legend>条件搜索</legend>
      <div class="layui-field-box">
        <form class="layui-form layui-form-pane" action="{:url('/store/article')}" method="GET">
          <div class="layui-form-item">
            <div class="layui-inline">
              <label class="layui-form-label">文章分类</label>
                <div class="layui-input-inline">
                  <select name="cid" class="layui-select">
                    <option value="">请选择文章分类</option>
                    {foreach $articleCategoryOptions as $opt}
                      <option value="{$opt.id}">{$opt.category_name}</option>
                    {/foreach}
                  </select>
                </div>
            </div>
            <div class="layui-inline">
              <label class="layui-form-label">文章状态</label>
                <div class="layui-input-inline">
                  <select name="status">
                    <option value="">请选择状态</option>
                    <option value="1">已发布</option>
                    <option value="0">未发布</option>
                  </select>
                </div>
            </div>
           
            <div class="layui-inline">
              <label class="layui-form-label">文章标题</label>
              <div class="layui-input-inline">
                <input type="text" name="keyword"  placeholder="请输入文章标题" autocomplete="off" class="layui-input">
              </div> 
            </div>
            <div class="layui-inline">
              <div class="layui-input-inline">
                <button  class="layui-btn" lay-submit lay-filter="search">搜索</button>
              </div>
            </div>
          </div>
        </form>   
      </div>
    </fieldset>
    <form class="layui-form">
      <table class="layui-table">
        <thead>
          <tr>
          <th>ID</th>
          <th>文章标题</th>
          <th>状态</th>
          <th>创建时间</th>
          <th>更新时间</th>
          <th>操作</th>
          </tr> 
        </thead>
      <tbody>
      {foreach $list as $vo}
      <tr>
        <td>{$vo.id}</td>
        <td>{$vo.article_title}</td>
        <td>
            {empty name='$vo.status'}
              <span class="layui-font-red">未发布</span>
            {else/}  
              <span class="layui-font-green">已发布</span>
            {/empty}
        </td>
        <td>{$vo.create_time}</td>
        <td>{$vo.update_time}</td>
        <td>
          {empty name='$vo.status'}
          <a class="layui-btn layui-btn-sm layui-btn-primary layui-border-green switch"
            data-url="{:url('/store/article/switch')}"  
            data-status="1" 
            data-id="{$vo.id}">发布</a>
          {else/}  
          <a class="layui-btn layui-btn-sm layui-btn-primary layui-border-red switch" 
            data-url="{:url('/store/article/switch')}" 
            data-status="0" 
            data-id="{$vo.id}">取消发布</a>
          {/empty}
          <a class="layui-btn layui-btn-sm" href="{:url('/store/article/edit',['id'=> $vo.id])}">编辑</a>
          <a class="layui-btn layui-btn-sm layui-btn-danger del" data-url="{:url('/store/article/delete',['id'=> $vo.id])}">删除</a>
        </td>
      </tr>
      {/foreach}
      </tbody>
      </table>
      {$list|raw}
  </form> 
  </div>
</div>
<script>  
    layui.use('form', function(){
      var form = layui.form;

      form.render('checkbox');
      form.render('select');
    });              
</script>